﻿using System;
using System.ServiceModel;
using Microsoft.ServiceBus;

namespace Client
{
    class Program
    {
        static void Main(String[] args)
        {
            var channelFactory = new ChannelFactory<IOperationExecutorChannel>
                (
                    new NetTcpRelayBinding(),
                    new EndpointAddress(ServiceBusEnvironment.CreateServiceUri("sb", "dotnetmarche", "executor"))
                );

            channelFactory.Endpoint.Behaviors.Add
                (
                    new TransportClientEndpointBehavior
                        {
                            TokenProvider = TokenProvider.CreateSharedSecretTokenProvider("owner", "SHARED KEY=")
                        }
                );

            for (var i=0; i<100; i++)
            {
                using (var channel = channelFactory.CreateChannel())
                {
                    var result = channel.Sum(i, i + 1);
                    Console.WriteLine(result);
                }
            }
        }
    }
}
